<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/5/8
  Time: 10:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>Java代码编写</h1>
<%
    String str = "this is java code from jsp.";
    List<String> mylist = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        mylist.add("mylist"+i);
    }
    //内置对象可以直接使用，但是不能改名
    request.setAttribute("str",str);
    request.getAttribute(str);    //等价于${str}
    session.setAttribute("username","LCH");

%>
<h2>如何在html显示Java变量的值:jsp/El表达式</h2>
<p>jsp:<%=str%></p>
<h2>El表达式可以获取九大内置对象的属性值:</h2>
<p>EL:${str}</p>
<p>el取session里面的值:${sessionScope.username}</p>
<ul>
<%for (int i = 0; i <mylist.size() ; i++) { %>
      <li><%=mylist.get(i)%></li>

    <% } %>
</ul>
</body>
</html>
